﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class ManagePeople : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //test2.Attributes.Add("onClick", "confirm();");
        
    }
    protected void btnAddNewPerson_Click(object sender, EventArgs e)
    {
        ManagePerson managePer = new ManagePerson();
        //SqlDataAdapter dataAdapt = managePer.enterNewPerson();

    }
    protected void btnFindPerson_Click(object sender, EventArgs e)
    {
        //GridView1.DataSourceID = "SqlDataSource2";
        GridView1.DataBind();
    }
    protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {
        if (e.Exception != null)
        {
            lblConfirm.Text = "A database error has occured. <br /><br /> Message: " + e.Exception.Message;
            e.ExceptionHandled = true;
            e.KeepInEditMode = true;
        }
        else if (e.AffectedRows == 0)
            lblConfirm.Text = "Another user may have updated that record. <br /> Please try again.";
        else
            lblConfirm.Text = "Your record has been saved";
            GridView1.DataBind();
        
    }
    protected void DetailsView_ItemInserted(object sender, DetailsViewUpdatedEventArgs e)
    {
        if (e.Exception != null)
        {
            lblConfirm.Text = "A database error has occured. <br /><br /> Message: " + e.Exception.Message;
            e.ExceptionHandled = true;
            e.KeepInEditMode = true;
        }
        else if (e.AffectedRows == 0)
            lblConfirm.Text = "Another user may have updated that record. <br /> Please try again.";
        else
            lblConfirm.Text = "Your record has been saved";
        GridView1.DataBind();
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //DetailsView1.ChangeMode(DetailsViewMode.Edit);
        //lblNew.Text = "Edit Selected Record";
        //DetailsView1.DataBind();
        
    }
    protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
    {
        //lblNew.Text = "Enter New Person";
    }
    protected void btnAddNew_Click(object sender, EventArgs e)
    {
        DetailsView1.ChangeMode(DetailsViewMode.Insert);
        
    }

    protected void DetailsView1_OnInsert(object sender, DetailsViewCommandEventArgs e)
    { 
        //<script type='text/javascript'>alert('Person Added Successfully');
    }
}
